import BankingTaskListGUI.*;
import java.util.ArrayList;


public class BankingService {
    private BankingTaskManager bankingTaskManager;
    public BankingService() {
        bankingTaskManager = new BankingTaskManager();
    }
    public void createAccount(String accountNumber, double initialBalance, double interestRate) {
        try {
            // Create account
            bankingTaskManager.createAccount(accountNumber, initialBalance, interestRate);
        } catch (NumberFormatException ex) {
            System.err.println("Invalid account number: " + accountNumber);
        } catch (Exception ex) {
            System.err.println("Error while creating account: " + ex.getMessage());
        }
    }
    public boolean deposit(String accountNumber, double amount) {
        try {
            // Deposit money
            bankingTaskManager.deposit(accountNumber, amount);
            return true;
        } catch (NumberFormatException ex) {
            System.err.println("Invalid account number: " + accountNumber);
            return false;
        } catch (Exception ex) {
            System.err.println("Error while depositing: " + ex.getMessage());
            return false;
        }
    }
    public boolean withdraw(String accountNumber, double amount) {
        try {
            // Withdraw money
            bankingTaskManager.withdraw(accountNumber, amount);
            return true;
        } catch (NumberFormatException ex) {
            System.err.println("Invalid account number: " + accountNumber);
            return false;
        } catch (Exception ex) {
            System.err.println("Error while withdrawing: " + ex.getMessage());
            return false;
        }
    }
    public double getBalance(String accountNumber) {
        try {
            return bankingTaskManager.getBalance(accountNumber);
        } catch (NumberFormatException ex) {
            System.err.println("Invalid account number: " + accountNumber);
            return -1;
        } catch (Exception ex) {
            System.err.println("Error while getting balance: " + ex.getMessage());
            return -1;
        }
    }
    public ArrayList<String> listHighPriorityTasks() {
        return bankingTaskManager.getHighPriorityTasks();
    }
}
